package ucadminlogic

import (
	"context"
	"go.uber.org/zap"
	"navi-mumbai/common/utils"
	"navi-mumbai/common/xerr"

	"navi-mumbai/app/rpc/usercenter/internal/svc"
	"navi-mumbai/app/rpc/usercenter/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteAppConfigLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteAppConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteAppConfigLogic {
	return &DeleteAppConfigLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 更新app配置
func (l *DeleteAppConfigLogic) DeleteAppConfig(in *pb.DeleteAppConfigReq) (*pb.DeleteAppConfigResp, error) {
	defer utils.RecoverPanic()
	var err error
	err = l.svcCtx.AppConfigModel.Delete(l.ctx, in.AppVersion)
	if err != nil {
		l.Logger.Errorf("err == ", zap.Error(err))
		return nil, xerr.NewGrpcErrCodeMsg(xerr.DbError, err.Error())
	}
	return &pb.DeleteAppConfigResp{}, nil
}
